#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_map>
using namespace std;
class Solution {
public:
    int majorityElement(vector<int>& nums) {
        int tmp = 0, ret = 0;
        unordered_map<int, int> hash;
        for (auto& n : nums)
        {
            ++hash[n];
            if (hash[n] > tmp)
            {
                ret = n;
                tmp = hash[n];
            }
        }
        return ret;

    }
};